package crawler.web.berkeleydb;

import library.database.mongo.ObjectId;

import com.sleepycat.je.DatabaseException;
import com.sleepycat.persist.EntityStore;
import com.sleepycat.persist.PrimaryIndex;
import com.sleepycat.persist.SecondaryIndex;

import crawler.web.beans.PageFingerPrint;

public class SimpleDA {

	// Index Accessors
	PrimaryIndex<ObjectId, PageFingerPrint> pIdx;
	SecondaryIndex<String, ObjectId, PageFingerPrint> sIdx;

	// Open the indices
	public SimpleDA(EntityStore store) throws DatabaseException {

		// Primary key for SimpleEntityClass classes
		pIdx = store.getPrimaryIndex(ObjectId.class, PageFingerPrint.class);

		// Secondary key for SimpleEntityClass classes
		// Last field in the getSecondaryIndex() method must be
		// the name of a class member; in this case, an 
		// SimpleEntityClass.class data member.
		sIdx = store.getSecondaryIndex(pIdx, String.class, "fingerPrint");
	}
}